#include "MyDockWidget.h"
#include <QTimer>
#include <QDebug>
#include <QGraphicsItem>

MyDockWidget::MyDockWidget(QWidget *parent) :
    QDockWidget(parent)
{
    m_graphicsView = new QGraphicsView(this);
    setWidget(m_graphicsView);
}

void MyDockWidget::resizeEvent(QResizeEvent *event)
{
    QDockWidget::resizeEvent(event);
    fitInView();
}

void MyDockWidget::setGraphicsScene(QGraphicsScene* pScene)
{
    m_graphicsView->setScene(pScene);
}

void MyDockWidget::fitInView()
{
    QRectF bounds = m_graphicsView->scene()->itemsBoundingRect();
    m_graphicsView->setSceneRect(bounds);
    m_graphicsView->scene()->setSceneRect(bounds);
    m_graphicsView->fitInView(bounds, Qt::KeepAspectRatio);
}
